#!/bin/bash

# oldstr=simple_peripheral_cc2640r2lp_oad_offchip_basic_simple_0.0.19.2
# newstr=simple_peripheral_cc2640r2lp_oad_offchip_basic_simple_0.0.19.3

# path=../*offchip_stack/FlashROM/
# sed -i "s/$oldstr/$newstr/g" `grep $oldstr -rl $path`

# path=../*offchip_app/FlashROM/
# sed -i "s/$oldstr/$newstr/g" `grep $oldstr -rl $path`

## User part
#########################################################################################
old_xdctools_core_path=/home/hemingway/ti/ccs1010/xdctools_3_61_02_27_core
new_xdctools_core_path=/home/hemingway/ti/xdctools_core

old_simplelink_cc2640r2_sdk_path=/home/hemingway/ti/simplelink_cc2640r2_sdk_4_20_00_04
new_simplelink_cc2640r2_sdk_path=/home/hemingway/ti/simplelink_cc2640r2_sdk

old_ti_cgi_arm_path=/home/hemingway/ti/ccs1010/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS
new_ti_cgi_arm_path=/home/hemingway/ti/ti_cgi_arm

old_stack_path=/home/hemingway/workstation/ccs/cc2640r2f_oad_onchip_uart/simple_peripheral_cc2640r2lp_oad_onchip_stack
new_stack_path=/home/hemingway/workstation/cc2640r2f_oad_onchip_uart/simple_peripheral_cc2640r2lp_oad_onchip_stack

old_mother_path=/home/hemingway/workstation/ccs/cc2640r2f_oad_onchip_uart
new_mother_path=/home/hemingway/workstation/cc2640r2f_oad_onchip_uart

app_path=../simple_peripheral_cc2640r2lp_oad_onchip_app/FlashROM/

#########################################################################################
old_xdctools_core_path=${old_xdctools_core_path//\//\\\/}
new_xdctools_core_path=${new_xdctools_core_path//\//\\\/}

old_simplelink_cc2640r2_sdk_path=${old_simplelink_cc2640r2_sdk_path//\//\\\/}
new_simplelink_cc2640r2_sdk_path=${new_simplelink_cc2640r2_sdk_path//\//\\\/}

old_ti_cgi_arm_path=${old_ti_cgi_arm_path//\//\\\/}
new_ti_cgi_arm_path=${new_ti_cgi_arm_path//\//\\\/}

old_stack_path=${old_stack_path//\//\\\/}
new_stack_path=${new_stack_path//\//\\\/}

old_mother_path=${old_mother_path//\//\\\/}
new_mother_path=${new_mother_path//\//\\\/}

# grep -rl $old_xdctools_core_path $app_path | xargs sed -i "s/$old_xdctools_core_path/$new_xdctools_core_path/g"
# grep -rl $old_simplelink_cc2640r2_sdk_path $app_path | xargs sed -i "s/$old_simplelink_cc2640r2_sdk_path/$new_simplelink_cc2640r2_sdk_path/g"
# grep -rl $old_ti_cgi_arm_path $app_path | xargs sed -i "s/$old_ti_cgi_arm_path/$new_ti_cgi_arm_path/g"
# grep -rl $old_stack_path $app_path | xargs sed -i "s/$old_stack_path/$new_stack_path/g"
grep -rl $old_mother_path $app_path | xargs sed -i "s/$old_mother_path/$new_mother_path/g"

